* DTA with list of events
preserve
drop if largeDevaluation==.
keep ccode year country gRER imfcode 
ren year devaluationYear
ren imfcode CountryCode
sort ccode devaluationYear
bys ccode: gen episode=_n
sort ccode
save "temp/Depreciation Events.dta", replace
restore

* Create DTA with number of events per country used to construct figures
preserve
drop if largeDevaluation==.
keep ccode year
gen dum=1
bys ccode: egen numbepi = total(dum)
drop dum
bys ccode: gen counter=_n
bys ccode: egen yearlast = max(year) // record year of last event
keep if counter==1
drop counter
sort ccode
cd temp
save "Numb Events by Country.dta", replace
cd ..
restore
